package com.woniu.user.config;

import com.woniu.user.interceptor.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 配置拦截器 用于令牌校验
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    private Authentication authentication;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authentication)
                .excludePathPatterns("/comment/addComment",
                        "/account/login",
                        "/venue/venueLogin",
                        "/account/register",
                        "/account/active**",
                        "/account/checkEmail**",
                        "/account/sendCode**",
                        "/account/checkCode**",
                        "/account/resetPwd",
                        "/account/active/**",
                        "/favicon.ico",
                        "/account/alipayCallback**",// 支付宝异步回调
                        "/html/venueLogin.html",
                        "/html/venueLogin.html",
                        "/html/register.html",
                        "/html/article.html",
                        "/html/activeSuccess.html",
                        "/html/findPass.html",
                        "/user/login.html",
                        "/user/login.html",
                        "/user/register.html",
                        "/user/article.html",
                        "/user/activeSuccess.html",
                        "/user/findPass.html",
                        "/coach/login.html",
                        "/coach/register.html",
                        "/coach/article.html",
                        "/coach/activeSuccess.html",
                        "/coach/findPass.html",
                        "/venue/venueLogin.html",
                        "/venue/venueRegister.html",
                        "/venue/venueFindPass.html",
                        "/venue/article.html",
                        "/venue/activeSuccess.html",
                        "/venue/login",
                        "/venue/emailCode",
                        "/venue/venueLogin",
                        "/venue/venueRegister",
                        "/venue/active**",
                        "/venue/checkEmail**",
                        "/venue/sendCode**",
                        "/venue/checkCode**",
                        "/venue/resetPwd",
                        "/venue/venueActive/**",
                        "/venue/active/**",
                        "/js/**", "/css/**", "/photo/**");// 不拦截的请求
    }
}